/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.lucava.lib.client.control;

import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.SimplePanel;
import org.lucava.lib.client.event.InitEvent;
import org.lucava.lib.client.event.InitHandlersEvent;
import org.lucava.lib.client.handler.InitControlHandler;
import org.lucava.lib.client.layout.LayoutManager;

/**
 *
 * @author glenn
 */
public abstract class Control implements InitControlHandler {

    private EventBus eventBus;
    private LayoutManager layoutManager;

    public final void init() {

        eventBus.addHandler(InitEvent.TYPE, this);
        eventBus.addHandler(InitHandlersEvent.TYPE, this);
    }

    public void setEventBus(EventBus eventBus) {
        this.eventBus = eventBus;
    }

    public EventBus getEventBus() {
        return eventBus;
    }

    public void assignView(String key, Composite view) {
        this.getLayoutManager().attachView(key, view.asWidget());


    }

    public LayoutManager getLayoutManager() {
        return layoutManager;
    }

    public void setLayoutManager(LayoutManager layoutManager) {
        this.layoutManager = layoutManager;
    }
}
